﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace Result
{
    class Program
    {
        static void Main(string[] args)
        {
            String total = "", executed = "", passed = "", Msg = "";
            try
            {
                XmlDocument reader = new XmlDocument();
                reader.Load("D:\\test\\MapMerge1\\TestResults\\SoftTest.trx");
                XmlNode root = reader.DocumentElement;
                foreach (XmlNode personElement in root.ChildNodes)
                {
                    if (personElement.Name.Equals("ResultSummary"))
                    {
                        foreach (XmlNode xn in personElement.ChildNodes)
                        {
                            if (xn.Name.Equals("Counters"))
                            {
                                total = xn.Attributes["total"].Value;
                                passed = xn.Attributes["passed"].Value;
                                executed = xn.Attributes["executed"].Value;
                                break;
                            }
                        }
                        break;
                    }
                }
                StreamWriter sw = new StreamWriter("D:\\result\\UnitTestResult\\Count.txt");
                Msg = "total=" + total + " executed=" + executed + " passed=" + passed;
                sw.WriteLine(Msg);
                sw.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }
    }
}
